﻿/*********************************************************************
 *
 *                             NOTICE
 *               COPYRIGHT (c) 2012 Panoscopix Software, Inc.
 *                UNPUBLISHED - ALL RIGHTS RESERVED
 * 
 *      This program is confidential, proprietary, and a trade
 *   secret of Panoscopix Software, Inc. The receipt or possession of
 *     this program does not convey any rights to reproduce or
 *      disclose its contents, or to manufacture, use, or sell
 *       anything that it may describe, in whole or in part, 
 *   without the specific written consent of Panoscopix Software, Inc.
 *
 * A Node interface for common File and Directory components.
 * 
 *******************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FileSystem
{
    public interface IFSNode
    {
        /// <summary>
        /// Parent of this node, if any (null if root or orphan).
        /// </summary>
        IFSDirectory getParent();

        /// <summary>
        /// Sets the parent of this node to specified parent.  Does not add this
        /// node to the parent.
        /// </summary>
        /// <param name="parent">New parent node (if any) of this node.</param>
        void setParent(IFSDirectory parent);

        /// <summary>
        /// ID of this node (globally unique, can't change).
        /// </summary>
        String getID();

        /// <summary>
        /// Name of this node...only locally unique.
        /// </summary>
        String getName();

        /// <summary>
        /// Fully Qualified Name of this node; globally unique.
        /// </summary>
        /// <returns></returns>
        String getFQName();

        /// <summary>
        /// Changes the local name of this node to newName.
        /// </summary>
        /// <param name="newName">Should not be null or empty, and should be locally unique.</param>
        void rename(String newName);

        /// <summary>
        /// The size of the node.
        /// </summary>
        int getSize();	

        /// <summary>
        /// The creation date/timestamp.
        /// </summary>
        String getCreationTimestamp();	

        /// <summary>
        /// String of the contents of this node; will not be null (will at least be empty string).
        /// </summary>
        String getContents();

        /// <summary>
        /// Return a description string for this object (only, no contained nodes).
        /// </summary>
        /// <returns>Description string.</returns>
        String describe();

        /// <summary>
        /// Return a description string for this object (and contained nodes) using context.
        /// </summary>
        /// <param name="context">PrintContext (indent level) for the description.</param>
        /// <returns>Description string.</returns>
        String describe(IPrintContext context);

        /// <summary>
        /// Returns number of nodes contained within this one.
        /// </summary>
        int numNodes();

        /// <summary>
        /// Contained node at index i; null if i >= numNodes().
        /// </summary>
        /// <param name="i">The child node index.</param>
        IFSNode getNode(int i);

        /// <summary>
        /// Add node with name, if possible (this has to accept nodes; name has to be unique among siblings).
        /// If added, the node.setParent(this).
        /// </summary>
        /// <param name="node">The node to add.</param>
        /// <returns>True if node added.</returns>
        bool addNode(IFSNode node);

        /// <summary>
        /// Remove node with name, if possible (name has to be presently contained).
        /// The returned node's parent is set to NULL.
        /// </summary>
        /// <param name="name">The node name to remove.</param>
        /// <returns>The node removed; null if no removal.</returns>
        IFSNode removeNode(String name);

        /// <summary>
        /// Accepts the specified visitor.
        /// </summary>
        /// <param name="visitor">The visitor.</param>
        void Accept(INodeVisitor visitor);
    }
}
